package mop.exception;

/**
 * Exception class for incorrect names
 * 
 * @author	 MOP Team 7
 */
public class IllegalNameException extends Throwable 
{

	/**
	 * Initializes an IllegalNameException with the passed name
	 * 
	 * @param name	The name thats incorrect
	 *  
	 * @effect set the name
	 */
	public IllegalNameException(String name)
	{
		this.setName(name);	
	}
	
	/**
	 * Return a error message that can be used by the gui
	 * @return An error message describing the incorrect name
	 */
	public String toString()
	{
		
		StringBuffer sb = new StringBuffer();
		sb.append("The following name is not a valid one ! ");
		
		if(this.name == null)
			sb.append("NULL");
		else if(this.name.trim().equals(""))
		{
			sb.append("/emptyString");
		}
		else
		{
			sb.append(this.name);
		}
		
		return sb.toString();
		
	}
	
	 /**
	  * Set the name
	  * 
	  * @param name	The name that's causing a racket
	  *  
	  * @post The name is set to the passed one
	  */
	 private void setName(String name) 
	 {

		 this.name = name;
	 }
	
	/**
	 * Weird java demand
	 */
	private static final long serialVersionUID = 1L;
	
	/**
	 * The name thats causing the problem
	 */
	private String name;
	
}
